﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Chinook.Web.Dms
{
    public partial class FileSystemBasedConnector : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //declare variable to hold dir
            string dir;
            //check whether dir is null or it's length is less than zero
            if (Request.Form["dir"] == null || Request.Form["dir"].Length <= 0)
                //return's nothing
                dir = "/";
            else
                //else, get the directory value
                dir = Server.UrlDecode(Request.Form["dir"]);
            //get the directory info by passing dir value
            var di = new System.IO.DirectoryInfo(dir);
            //Initialize the ul with class Jquery file tree to bind
            Response.Write("<ul class=\"jqueryFileTree\" style=\"display: none;\">\n");
            //loop for each directory
            foreach (var diChild in di.GetDirectories())
                //write the each folder name with the directory to list item
                Response.Write("\t<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + dir + diChild.Name + "/\">" +
                               diChild.Name + "</a></li>\n");
            //close the ul tag
            Response.Write("</ul>");
        }
    }
}
